package com.lsl.agency;

import cn.hutool.aop.ProxyUtil;
import cn.hutool.aop.aspects.Aspect;
import cn.hutool.aop.aspects.TimeIntervalAspect;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import org.junit.Test;

import java.lang.reflect.Method;

/**
 * @author lishuailong
 * @create 2020-07-17 11:39
 */
public class test3 {
    @Test
    public void test1(){
        Person re = new Person();
        Person proxy = ProxyUtil.proxy(re, new Aspect() {
            @Override
            public boolean before(Object target, Method method, Object[] args) {
                System.out.println("开始了吗！");
                return true;
            }

            @Override
            public boolean after(Object target, Method method, Object[] args) {
                System.out.println("已经结束了！");
                return true;
            }

            @Override
            public boolean afterException(Object target, Method method, Object[] args, Throwable e) {
                System.out.println("翻车了！");
                return true;
            }
        });
        proxy.chi();
    }
}
class Person {
    void chi(){
        System.out.println("吃饭！");
        throw new IllegalArgumentException("");
    }
}
